from .base_controller import BaseController
# from util.visualizer import Visualizer
import time
from data import create_dataset
from models import create_model
import numpy as np
class predeal_controller(BaseController):
    def modify_commandline_options(parser,flagdict=None):
        # parser.set_defaults(usemodel=False)
        # parser.add_argument('--xreverse', type=int, default=1, help='')
        # parser.add_argument('--yreverse', type=int, default=1, help='')
        # parser.add_argument('--zreverse', type=int, default=1, help='')
        # parser.add_argument('--ballradius', type=int, default=2, help='render ball radius')
        # parser.add_argument('--cvh', type=int, default=128*6, help='heigh of display windows')
        # parser.add_argument('--cvw', type=int, default=128*9, help='width of display windows')
        # parser.add_argument('--cvz', type=int, default=300*3, help='deep of display windows')
        # parser.add_argument('--showrot', type=bool, default=False, help='show rotation or not')
        # parser.add_argument('--magnifyBlue', type=int, default=0, help='magnifyBlue')
        # parser.add_argument('--freezerot', type=bool, default=False, help='freeze rotation or not')
        # parser.add_argument('--normalizecolor', type=bool, default=True, help='use normalizecolor or not')
        # parser.add_argument('--waittime', type=int, default=0, help='time of windows delay')
        # parser.add_argument('--display_3d', type=bool, default=True, help='')
        # parser.add_argument('--phase', type=str, default='display_zed_camera', help='')
        # parser.add_argument('--pclnpoints', type=int, default=2000000, help='')

        return parser
    
    def __init__(self,opt):
        BaseController.__init__(self,opt)
        
        self.opt = opt   # get training options
        datasets = opt.dataset_mode
        self.datasets = create_dataset(opt)

        self.models = [None]
        if opt.usemodel :
            self.models.append(create_model(self.opt))      # create a model given opt.model and other options
            self.models[len(self.model)-1].setup(self.opt)               # regular setup: load and print networks; create schedulers

        opt.grab_pcl_fuc = self.get_data
        opt.switch_model_func = self.switch_model
        opt.switch_pcl_func = self.switch_pcl

        self.curpcl = 0
        self.curmodel = 0
        self.datasets.dataset.change_options(self.opt)
        self.npoints = opt.pclnpoints

    def excute(self):
        self.vis.run_pcl_dsiplay_process()
 